<?	/*
	// File:	monitor.php
	// Purpose:	Services monitor script:  check the pids.
	// Author:	Felix <webmaster@can-host.com>
	// Modified:	Added ram, swap, uptime data saved to files for getstat in web/functions.inc.phps
	*/

// This has been moved to monitor.mod.phps
/*
///////////////////////
// CONFIGURATION :  filename containing the scan data
$filename = $cfg['basedir']."/server/data/sysmon.dat";

unset($monitor);

$monitor = array();
call_hook('server:service:monitor', &$monitor);

// Prepare $data
$data = serialize($monitor);
// write down results
$fp = fopen($filename,"w+");
fwrite($fp,$data,strlen($data));
fclose($fp);

// get stat (server-side)
$filepath = $cfg['basedir']."/server/data/";

// get RAM information
$ram_total = trim(`free -m |grep -i mem | cut -c15-18`);
$ram_used = trim(`free -m |grep -i mem | cut -c26-29`);
// write down results
$fp = fopen($filepath."ram.dat","w+");
fwrite($fp,$ram_used." / ".$ram_total,50000);
fclose($fp);

// get SWAP information
$swap_total = trim(`free -m |grep -i swap | cut -c15-18`);
$swap_used = trim(`free -m |grep -i swap | cut -c26-29`);
// write down results
$fp = fopen($filepath."swap.dat","w+");
fwrite($fp,$swap_used." / ".$swap_total,50000);
fclose($fp);

// get server uptime
$serverinfo = trim(`uptime | cut -c11-`);
// write down results
$fp = fopen($filepath."uptime.dat","w+");
fwrite($fp,$serverinfo,strlen($serverinfo));
fclose($fp);
*/
?>
